import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart';
import 'package:tiktokadult/assets_tool/images.dart';
import 'package:tiktokadult/hj_page/mine_business/mine_setting/mine_setting_profile_controller.dart';
import 'package:tiktokadult/hj_utils/widget_utils.dart';
import 'package:tiktokadult/tools_base/global_store/store.dart';

class SettingNickName extends StatefulWidget {
  const SettingNickName({super.key});

  @override
  State<SettingNickName> createState() => _SettingNickNameState();
}

class _SettingNickNameState extends State<SettingNickName> {
  late final controller = Get.find<MineSettingProfilePage>();
  @override
  void initState() {
    super.initState();
    controller.nickNameTfCtr.text = globalStore.meInfo?.name ?? '';
  }

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.symmetric(horizontal: 16),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          60.sizeBoxH,
          Row(
            children: [
              Expanded(
                child: TextField(
                  controller: controller.nickNameTfCtr,
                  maxLength: 20,
                  style: TextStyle(color: Colors.white.withOpacity(0.9), fontSize: 18),
                  decoration: InputDecoration(
                      border: InputBorder.none,
                      hintText: '输入新的昵称',
                      hintStyle: TextStyle(color: Colors.white.withOpacity(0.35), fontSize: 18),
                      counterText: '',
                      isCollapsed: true,
                      contentPadding: EdgeInsets.zero),
                ),
              ),
              InkWell(
                onTap: () => controller.nickNameTfCtr.clear(),
                child: Container(
                    padding: EdgeInsets.all(2),
                    decoration: BoxDecoration(color: Colors.black.withOpacity(0.9), borderRadius: BorderRadius.circular(90)),
                    child: Image.asset(
                      'close_button.png'.commonImgPath,
                      width: 24,
                    )),
              )
            ],
          ),
          12.sizeBoxH,
          0.5.line,
          12.sizeBoxH,
          Text(
            '注意*诱导性昵称会被投诉封号',
            style: TextStyle(color: Colors.white.withOpacity(0.35), fontSize: 12),
          )
        ],
      ),
    );
  }
}

class SettingSlogan extends StatefulWidget {
  const SettingSlogan({super.key});

  @override
  State<SettingSlogan> createState() => _SettingSloganState();
}

class _SettingSloganState extends State<SettingSlogan> {
  late final controller = Get.find<MineSettingProfilePage>();

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(left: 16, top: 12, right: 16),
      padding: EdgeInsets.all(10),
      decoration: BoxDecoration(color: Colors.black.withOpacity(.04), borderRadius: BorderRadius.circular(8)),
      constraints: BoxConstraints(
        minHeight: 111,
      ),
      child: Stack(
        children: [
          TextField(
            maxLines: 10,
            style: const TextStyle(color: Color(0xff333333), fontSize: 12),
            maxLength: 150,
            controller: controller.sloganTfCtr,
            decoration: InputDecoration(
                border: InputBorder.none,
                hintText: '有趣的介绍能让你的逼格提高N个档次！...',
                hintStyle: TextStyle(color: Color(0xff999999), fontSize: 12),
                counterText: '',
                contentPadding: EdgeInsets.zero,
                isDense: true),
          ),
          Positioned(
            child: ChangeNotifierProvider(
              create: (_) => controller.sloganTfCtr,
              child: Consumer<TextEditingController>(
                builder: (__, ctr, child) => Text(
                  '${ctr.text.length}/150',
                  style: TextStyle(
                    color: Color(0xff666666),
                    fontSize: 12,
                  ),
                ),
              ),
            ),
            bottom: 0,
            right: 0,
          )
        ],
      ),
    );
  }
}
